home *** CD-ROM | disk | FTP | other *** search
/ QuickTime 2.0 Developer Kit / QuickTime 2.0 Developer Kit.iso / mac / MAC / Programming Stuff / Interfaces / CIncludes / Connections.h < prev    next >
Encoding:
C/C++ Source or Header  |  1994-11-11  |  12.8 KB  |  363 lines  |  [TEXT/MPS ]

  1. /*
  2.      File:        Connections.h
  3.  
  4.      Copyright:    © 1984-1994 by Apple Computer, Inc.
  5.                  All rights reserved.
  6.  
  7.      Version:    Universal Interfaces 2.0a3  ETO #16, MPW prerelease.  Friday, November 11, 1994. 
  8.  
  9.      Bugs?:        If you find a problem with this file, send the file and version
  10.                  information (from above) and the problem description to:
  11.  
  12.                      Internet:    apple.bugs@applelink.apple.com
  13.                      AppleLink:    APPLE.BUGS
  14.  
  15. */
  16.  
  17. #ifndef __CONNECTIONS__
  18. #define __CONNECTIONS__
  19.  
  20.  
  21. #ifndef __WINDOWS__
  22. #include <Windows.h>
  23. #endif
  24. /*    #include <Memory.h>                                            */
  25. /*        #include <Types.h>                                        */
  26. /*            #include <ConditionalMacros.h>                        */
  27. /*        #include <MixedMode.h>                                    */
  28. /*    #include <Quickdraw.h>                                        */
  29. /*        #include <QuickdrawText.h>                                */
  30. /*    #include <Events.h>                                            */
  31. /*        #include <OSUtils.h>                                    */
  32. /*    #include <Controls.h>                                        */
  33. /*        #include <Menus.h>                                        */
  34.  
  35. #ifndef __DIALOGS__
  36. #include <Dialogs.h>
  37. #endif
  38. /*    #include <Errors.h>                                            */
  39. /*    #include <TextEdit.h>                                        */
  40.  
  41. #ifndef __CTBUTILITIES__
  42. #include <CTBUtilities.h>
  43. #endif
  44. /*    #include <StandardFile.h>                                    */
  45. /*        #include <Files.h>                                        */
  46. /*    #include <AppleTalk.h>                                        */
  47.  
  48. #ifdef __cplusplus
  49. extern "C" {
  50. #endif
  51.  
  52. #if GENERATINGPOWERPC
  53. #pragma options align=mac68k
  54. #endif
  55.  
  56. #ifdef __CFM68K__
  57. #pragma lib_export on
  58. #endif
  59.  
  60.  
  61. enum {
  62. /*    current Connection Manager version    */
  63.     curCMVersion                = 2,
  64. /*    current Connection Manager Environment Record version     */
  65.     curConnEnvRecVers            = 0,
  66. /* CMErr */
  67.     cmGenericError                = -1,
  68.     cmNoErr                        = 0,
  69.     cmRejected                    = 1,
  70.     cmFailed                    = 2,
  71.     cmTimeOut                    = 3,
  72.     cmNotOpen                    = 4,
  73.     cmNotClosed                    = 5,
  74.     cmNoRequestPending            = 6,
  75.     cmNotSupported                = 7,
  76.     cmNoTools                    = 8,
  77.     cmUserCancel                = 9,
  78.     cmUnknownError                = 11
  79. };
  80.  
  81. typedef OSErr CMErr;
  82.  
  83.  
  84. enum {
  85.     cmData                        = 1L << 0,
  86.     cmCntl                        = 1L << 1,
  87.     cmAttn                        = 1L << 2,
  88.     cmDataNoTimeout                = 1L << 4,
  89.     cmCntlNoTimeout                = 1L << 5,
  90.     cmAttnNoTimeout                = 1L << 6,
  91.     cmDataClean                    = 1L << 8,
  92.     cmCntlClean                    = 1L << 9,
  93.     cmAttnClean                    = 1L << 10,
  94. /*        Only for CMRecFlags (not CMChannel) in the rest of this enum    */
  95.     cmNoMenus                    = 1L << 16,
  96.     cmQuiet                        = 1L << 17,
  97.     cmConfigChanged                = 1L << 18
  98. };
  99.  
  100. /* CMRecFlags and CMChannel        */
  101. /*        Low word of CMRecFlags is same as CMChannel    */
  102. typedef long CMRecFlags;
  103.  
  104. typedef short CMChannel;
  105.  
  106.  
  107. enum {
  108.     cmStatusOpening                = 1L << 0,
  109.     cmStatusOpen                = 1L << 1,
  110.     cmStatusClosing                = 1L << 2,
  111.     cmStatusDataAvail            = 1L << 3,
  112.     cmStatusCntlAvail            = 1L << 4,
  113.     cmStatusAttnAvail            = 1L << 5,
  114.     cmStatusDRPend                = 1L << 6,                        /* data read pending    */
  115.     cmStatusDWPend                = 1L << 7,                        /* data write pending    */
  116.     cmStatusCRPend                = 1L << 8,                        /* cntl read pending    */
  117.     cmStatusCWPend                = 1L << 9,                        /* cntl write pending    */
  118.     cmStatusARPend                = 1L << 10,                        /* attn read pending    */
  119.     cmStatusAWPend                = 1L << 11,                        /* attn write pending    */
  120.     cmStatusBreakPend            = 1L << 12,
  121.     cmStatusListenPend            = 1L << 13,
  122.     cmStatusIncomingCallPresent    = 1L << 14,
  123.     cmStatusReserved0            = 1L << 15
  124. };
  125.  
  126. typedef unsigned long CMStatFlags;
  127.  
  128.  
  129. enum {
  130.     cmDataIn,
  131.     cmDataOut,
  132.     cmCntlIn,
  133.     cmCntlOut,
  134.     cmAttnIn,
  135.     cmAttnOut,
  136.     cmRsrvIn,
  137.     cmRsrvOut
  138. };
  139.  
  140. typedef unsigned short CMBufFields;
  141.  
  142. typedef Ptr CMBuffers[8];
  143.  
  144. typedef long CMBufferSizes[8];
  145.  
  146. typedef const long *ConstCMBufferSizesParam;
  147.  
  148.  
  149. enum {
  150.     cmSearchSevenBit            = 1L << 0
  151. };
  152.  
  153. typedef unsigned short CMSearchFlags;
  154.  
  155.  
  156. enum {
  157.     cmFlagsEOM                    = 1L << 0
  158. };
  159.  
  160. typedef unsigned short CMFlags;
  161.  
  162. struct ConnEnvironRec {
  163.     short                            version;
  164.     long                            baudRate;
  165.     short                            dataBits;
  166.     CMChannel                        channels;
  167.     Boolean                            swFlowControl;
  168.     Boolean                            hwFlowControl;
  169.     CMFlags                            flags;
  170. };
  171. typedef struct ConnEnvironRec ConnEnvironRec;
  172.  
  173. typedef ConnEnvironRec *ConnEnvironRecPtr;
  174.  
  175. typedef struct ConnRecord ConnRecord, *ConnPtr, **ConnHandle;
  176.  
  177. typedef pascal long (*ConnectionToolDefProcPtr)(ConnHandle hConn, short msg, long p1, long p2, long p3);
  178. typedef pascal void (*ConnectionSearchCallBackProcPtr)(ConnHandle hConn, Ptr matchPtr, long refNum);
  179. typedef pascal void (*ConnectionCompletionProcPtr)(ConnHandle hConn);
  180. typedef pascal void (*ConnectionChooseIdleProcPtr)(void);
  181.  
  182. #if GENERATINGCFM
  183. typedef UniversalProcPtr ConnectionToolDefUPP;
  184. typedef UniversalProcPtr ConnectionSearchCallBackUPP;
  185. typedef UniversalProcPtr ConnectionCompletionUPP;
  186. typedef UniversalProcPtr ConnectionChooseIdleUPP;
  187. #else
  188. typedef ConnectionToolDefProcPtr ConnectionToolDefUPP;
  189. typedef ConnectionSearchCallBackProcPtr ConnectionSearchCallBackUPP;
  190. typedef ConnectionCompletionProcPtr ConnectionCompletionUPP;
  191. typedef ConnectionChooseIdleProcPtr ConnectionChooseIdleUPP;
  192. #endif
  193.  
  194. struct ConnRecord {
  195.     short                            procID;
  196.     CMRecFlags                        flags;
  197.     CMErr                            errCode;
  198.     long                            refCon;
  199.     long                            userData;
  200.     ConnectionToolDefUPP            defProc;
  201.     Ptr                                config;
  202.     Ptr                                oldConfig;
  203.     long                            asyncEOM;
  204.     long                            reserved1;
  205.     long                            reserved2;
  206.     Ptr                                cmPrivate;
  207.     CMBuffers                        bufferArray;
  208.     CMBufferSizes                    bufSizes;
  209.     long                            mluField;
  210.     CMBufferSizes                    asyncCount;
  211. };
  212.  
  213. enum {
  214. /* CMIOPB constants and structure */
  215.     cmIOPBQType                    = 10,
  216.     cmIOPBversion                = 0
  217. };
  218.  
  219. struct CMIOPB {
  220.     QElemPtr                        qLink;
  221.     short                            qType;                        /* cmIOPBQType */
  222.     ConnHandle                        hConn;
  223.     Ptr                                theBuffer;
  224.     long                            count;
  225.     CMFlags                            flags;
  226.     ConnectionCompletionUPP            userCompletion;
  227.     long                            timeout;
  228.     CMErr                            errCode;
  229.     CMChannel                        channel;
  230.     long                            asyncEOM;
  231.     long                            reserved1;
  232.     short                            reserved2;
  233.     short                            version;                    /* cmIOPBversion */
  234.     long                            refCon;                        /* for application */
  235.     long                            toolData1;                    /* for tool */
  236.     long                            toolData2;                    /* for tool */
  237. };
  238. typedef struct CMIOPB CMIOPB;
  239.  
  240. typedef CMIOPB *CMIOPBPtr;
  241.  
  242. enum {
  243.     uppConnectionToolDefProcInfo = kPascalStackBased
  244.          | RESULT_SIZE(SIZE_CODE(sizeof(long)))
  245.          | STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(ConnHandle)))
  246.          | STACK_ROUTINE_PARAMETER(2, SIZE_CODE(sizeof(short)))
  247.          | STACK_ROUTINE_PARAMETER(3, SIZE_CODE(sizeof(long)))
  248.          | STACK_ROUTINE_PARAMETER(4, SIZE_CODE(sizeof(long)))
  249.          | STACK_ROUTINE_PARAMETER(5, SIZE_CODE(sizeof(long))),
  250.     uppConnectionSearchCallBackProcInfo = kPascalStackBased
  251.          | STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(ConnHandle)))
  252.          | STACK_ROUTINE_PARAMETER(2, SIZE_CODE(sizeof(Ptr)))
  253.          | STACK_ROUTINE_PARAMETER(3, SIZE_CODE(sizeof(long))),
  254.     uppConnectionCompletionProcInfo = kPascalStackBased
  255.          | STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(ConnHandle))),
  256.     uppConnectionChooseIdleProcInfo = kPascalStackBased
  257. };
  258.  
  259. #if GENERATINGCFM
  260. #define CallConnectionToolDefProc(userRoutine, hConn, msg, p1, p2, p3)        \
  261.         CallUniversalProc((UniversalProcPtr)(userRoutine), uppConnectionToolDefProcInfo, (hConn), (msg), (p1), (p2), (p3))
  262. #define CallConnectionSearchCallBackProc(userRoutine, hConn, matchPtr, refNum)        \
  263.         CallUniversalProc((UniversalProcPtr)(userRoutine), uppConnectionSearchCallBackProcInfo, (hConn), (matchPtr), (refNum))
  264. #define CallConnectionCompletionProc(userRoutine, hConn)        \
  265.         CallUniversalProc((UniversalProcPtr)(userRoutine), uppConnectionCompletionProcInfo, (hConn))
  266. #define CallConnectionChooseIdleProc(userRoutine)        \
  267.         CallUniversalProc((UniversalProcPtr)(userRoutine), uppConnectionChooseIdleProcInfo)
  268. #else
  269. #define CallConnectionToolDefProc(userRoutine, hConn, msg, p1, p2, p3)        \
  270.         (*(userRoutine))((hConn), (msg), (p1), (p2), (p3))
  271. #define CallConnectionSearchCallBackProc(userRoutine, hConn, matchPtr, refNum)        \
  272.         (*(userRoutine))((hConn), (matchPtr), (refNum))
  273. #define CallConnectionCompletionProc(userRoutine, hConn)        \
  274.         (*(userRoutine))((hConn))
  275. #define CallConnectionChooseIdleProc(userRoutine)        \
  276.         (*(userRoutine))()
  277. #endif
  278.  
  279. #if GENERATINGCFM
  280. #define NewConnectionToolDefProc(userRoutine)        \
  281.         (ConnectionToolDefUPP) NewRoutineDescriptor((ProcPtr)(userRoutine), uppConnectionToolDefProcInfo, GetCurrentArchitecture())
  282. #define NewConnectionSearchCallBackProc(userRoutine)        \
  283.         (ConnectionSearchCallBackUPP) NewRoutineDescriptor((ProcPtr)(userRoutine), uppConnectionSearchCallBackProcInfo, GetCurrentArchitecture())
  284. #define NewConnectionCompletionProc(userRoutine)        \
  285.         (ConnectionCompletionUPP) NewRoutineDescriptor((ProcPtr)(userRoutine), uppConnectionCompletionProcInfo, GetCurrentArchitecture())
  286. #define NewConnectionChooseIdleProc(userRoutine)        \
  287.         (ConnectionChooseIdleUPP) NewRoutineDescriptor((ProcPtr)(userRoutine), uppConnectionChooseIdleProcInfo, GetCurrentArchitecture())
  288. #else
  289. #define NewConnectionToolDefProc(userRoutine)        \
  290.         ((ConnectionToolDefUPP) (userRoutine))
  291. #define NewConnectionSearchCallBackProc(userRoutine)        \
  292.         ((ConnectionSearchCallBackUPP) (userRoutine))
  293. #define NewConnectionCompletionProc(userRoutine)        \
  294.         ((ConnectionCompletionUPP) (userRoutine))
  295. #define NewConnectionChooseIdleProc(userRoutine)        \
  296.         ((ConnectionChooseIdleUPP) (userRoutine))
  297. #endif
  298.  
  299. extern pascal CMErr InitCM(void);
  300. extern pascal Handle CMGetVersion(ConnHandle hConn);
  301. extern pascal short CMGetCMVersion(void);
  302. extern pascal ConnHandle CMNew(short procID, CMRecFlags flags, ConstCMBufferSizesParam desiredSizes, long refCon, long userData);
  303. extern pascal void CMDispose(ConnHandle hConn);
  304. extern pascal CMErr CMListen(ConnHandle hConn, Boolean async, ConnectionCompletionUPP completor, long timeout);
  305. extern pascal CMErr CMAccept(ConnHandle hConn, Boolean accept);
  306. extern pascal CMErr CMOpen(ConnHandle hConn, Boolean async, ConnectionCompletionUPP completor, long timeout);
  307. extern pascal CMErr CMClose(ConnHandle hConn, Boolean async, ConnectionCompletionUPP completor, long timeout, Boolean now);
  308. extern pascal CMErr CMAbort(ConnHandle hConn);
  309. extern pascal CMErr CMStatus(ConnHandle hConn, CMBufferSizes sizes, CMStatFlags *flags);
  310. extern pascal void CMIdle(ConnHandle hConn);
  311. extern pascal void CMReset(ConnHandle hConn);
  312. extern pascal void CMBreak(ConnHandle hConn, long duration, Boolean async, ConnectionCompletionUPP completor);
  313. extern pascal CMErr CMRead(ConnHandle hConn, void *theBuffer, long *toRead, CMChannel theChannel, Boolean async, ConnectionCompletionUPP completor, long timeout, CMFlags *flags);
  314. extern pascal CMErr CMWrite(ConnHandle hConn, const void *theBuffer, long *toWrite, CMChannel theChannel, Boolean async, ConnectionCompletionUPP completor, long timeout, CMFlags flags);
  315. extern pascal CMErr CMIOKill(ConnHandle hConn, short which);
  316. extern pascal void CMActivate(ConnHandle hConn, Boolean activate);
  317. extern pascal void CMResume(ConnHandle hConn, Boolean resume);
  318. extern pascal Boolean CMMenu(ConnHandle hConn, short menuID, short item);
  319. extern pascal Boolean CMValidate(ConnHandle hConn);
  320. extern pascal void CMDefault(Ptr *theConfig, short procID, Boolean allocate);
  321. extern pascal Handle CMSetupPreflight(short procID, long *magicCookie);
  322. extern pascal Boolean CMSetupFilter(short procID, const void *theConfig, short count, DialogPtr theDialog, EventRecord *theEvent, short *theItem, long *magicCookie);
  323. extern pascal void CMSetupSetup(short procID, const void *theConfig, short count, DialogPtr theDialog, long *magicCookie);
  324. extern pascal void CMSetupItem(short procID, const void *theConfig, short count, DialogPtr theDialog, short *theItem, long *magicCookie);
  325. extern pascal void CMSetupXCleanup(short procID, const void *theConfig, short count, DialogPtr theDialog, Boolean OKed, long *magicCookie);
  326. extern pascal void CMSetupPostflight(short procID);
  327. extern pascal Ptr CMGetConfig(ConnHandle hConn);
  328. extern pascal short CMSetConfig(ConnHandle hConn, const void *thePtr);
  329. extern pascal OSErr CMIntlToEnglish(ConnHandle hConn, const void *inputPtr, Ptr *outputPtr, short language);
  330. extern pascal OSErr CMEnglishToIntl(ConnHandle hConn, const void *inputPtr, Ptr *outputPtr, short language);
  331. extern pascal long CMAddSearch(ConnHandle hConn, ConstStr255Param theString, CMSearchFlags flags, ConnectionSearchCallBackUPP callBack);
  332. extern pascal void CMRemoveSearch(ConnHandle hConn, long refnum);
  333. extern pascal void CMClearSearch(ConnHandle hConn);
  334. extern pascal CMErr CMGetConnEnvirons(ConnHandle hConn, ConnEnvironRec *theEnvirons);
  335. extern pascal short CMChoose(ConnHandle *hConn, Point where, ConnectionChooseIdleUPP idle);
  336. extern pascal void CMEvent(ConnHandle hConn, const EventRecord *theEvent);
  337. extern pascal void CMGetToolName(short procID, Str255 name);
  338. extern pascal short CMGetProcID(ConstStr255Param name);
  339. extern pascal void CMSetRefCon(ConnHandle hConn, long refCon);
  340. extern pascal long CMGetRefCon(ConnHandle hConn);
  341. extern pascal long CMGetUserData(ConnHandle hConn);
  342. extern pascal void CMSetUserData(ConnHandle hConn, long userData);
  343. extern pascal void CMGetErrorString(ConnHandle hConn, short id, Str255 errMsg);
  344. extern pascal CMErr CMNewIOPB(ConnHandle hConn, CMIOPBPtr *theIOPB);
  345. extern pascal CMErr CMDisposeIOPB(ConnHandle hConn, CMIOPBPtr theIOPB);
  346. extern pascal CMErr CMPBRead(ConnHandle hConn, CMIOPBPtr theIOPB, Boolean async);
  347. extern pascal CMErr CMPBWrite(ConnHandle hConn, CMIOPBPtr theIOPB, Boolean async);
  348. extern pascal CMErr CMPBIOKill(ConnHandle hConn, CMIOPBPtr theIOPB);
  349.  
  350. #ifdef __CFM68K__
  351. #pragma lib_export off
  352. #endif
  353.  
  354. #if GENERATINGPOWERPC
  355. #pragma options align=reset
  356. #endif
  357.  
  358. #ifdef __cplusplus
  359. }
  360. #endif
  361.  
  362. #endif /* __CONNECTIONS__ */
  363.